package com.samphanie.auiu.library.restful

/**
 * @author Dries
 **/
open class AuiuResponse<T> {

    companion object {
        const val SUCCESS: Int = 20000
        const val CACHE_SUCCESS: Int = 304
        const val RC_HAS_ERROR = 20001                   //有错误
        const val RC_ACCOUNT_INVALID = 10201            //账号不存在
        const val RC_PWD_INVALID = 10210               //密码错误
        const val RC_NEED_LOGIN = 10301               //请先登录
        const val RC_CHECK_SERVER_ERROR = 10001     //校验服务报错
        const val RC_USER_NAME_EXISTS = 10111      //此用户名被占用
        const val RC_HTML_INVALID = 8001         //请输入HTML
        const val RC_CONFIG_INVALID = 8002      //请输入配置

        const val RC_USER_FORBID = 10200           //用户身份非法
        const val RC_AUTH_TOKEN_EXPIRED = 10230    //访问Token过期，请重新设置
        const val RC_AUTH_TOKEN_INVALID = 10220    //访问Token不正确，请重新设置
    }

    var rawData: String? = null                   // 原始数据
    var code: Int = 20000                         // 业务状态码
    var data: T? = null                           // 业务数据
    var errorData: Map<String, String>? = null    // 错误状态下的数据

    var message: String? = null // 信息

    fun successful(): Boolean {
        return code == SUCCESS || code == CACHE_SUCCESS
    }

}